package com.fqxiny.aop01.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fqxiny.aop01.annotation.MyCache;
import com.fqxiny.aop01.annotation.MyCacheEL;
import com.fqxiny.aop01.domain.User;
import com.fqxiny.aop01.service.UserService;
import com.fqxiny.aop01.mapper.UserMapper;
import com.fqxiny.aop01.vo.UserVo;
import lombok.SneakyThrows;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @author 25312
* @description 针对表【user(用户表)】的数据库操作Service实现
* @createDate 2025-05-13 18:40:50
*/
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService{
    @Autowired
    private UserMapper userMapper;
    @Override
    @MyCacheEL(prefixKey = "data:user:", suffixKey = "#id")
    @SneakyThrows
    public UserVo getUserVo(Long id) {
        User user = userMapper.mySelectById(id);
        UserVo userVo = new UserVo();
        userVo.setAge(user.getAge());
        userVo.setName(user.getName());
        userVo.setPhone(user.getPhone());
        userVo.setGender(user.getGender());
        userVo.setEmail(user.getEmail());
        return userVo;
    }
}




